import requests

url = 'https://fanyi.baidu.com/sug'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
}

data = {
    'kw': '眼睛'
}

# post(url:请求地址, data:请求参数, kwargs:字典)
response = requests.post(url=url, data=data, headers=headers)

content = response.text
print(content)
# {"errno":0,"data":[{"k":"\u773c\u775b","v":"eye; lamp; opto-; glim; ocular"},{"k":"\u773c\u775b\u7684","v":"ocular; ophthalmic; optic; optical"},{"k":"\u773c\u775b\u86c7","v":"[\u533b]Cobra; Elapid snake; Naja; Spectacled cobra"},{"k":"\u773c\u775b\u75b2\u52b3","v":"eyestrain"},{"k":"\u773c\u775b\u65e0\u795e\u7684","v":"[\u533b]glassy-eye"}],"logid":2712929085}

# 引入json
import json

# 将json字符串转 json对象
obj = json.loads(content.encode('utf-8'))
print(obj)
# {'errno': 0, 'data': [{'k': '眼睛', 'v': 'eye; lamp; opto-; glim; ocular'}, {'k': '眼睛的', 'v': 'ocular; ophthalmic; optic; optical'}, {'k': '眼睛蛇', 'v': '[医]Cobra; Elapid snake; Naja; Spectacled cobra'}, {'k': '眼睛疲劳', 'v': 'eyestrain'}, {'k': '眼睛无神的', 'v': '[医]glassy-eye'}], 'logid': 2712929085}


# 总结
# 1.post请求，不需要编码
# 2.post请求，参数data
# 3.不需要请求对象定制